<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>

    <th:block th:include="include :: header('修改买房信息')" />
    <style>
        .returnToApartment:hover{
            background: transparent;
        }
        .returnToApartment{
            color: grey;
        }
        /*弹窗的样式*/
        .qback{
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,.3);
            position: fixed;
            top: 0;
            left: 0;
            z-index: 9999999999999999999999;
        }
        .alertBox{
            width: 452px;
            height: auto;
            padding: 0 15px 20px 15px;
            box-sizing: border-box;
            background: #fff;
            border-radius: 8px;
            position: relative;
            top: 50%;
            left: 50%;
            margin: -167px 0 0 -226px;
        }
        .alertHead{
            width: 100%;
            height: 45px;
            border-bottom: 1px solid #99bafa;
            font-size: 16px;
            color: #333;
            line-height: 45px;
            text-align: center;
        }
        .alertMes{
            width: 100%;
            height: auto;
            overflow: hidden;
            padding: 25px 40px 35px;
            text-align: center;
            font-size: 16px;
            color: #333;
            box-sizing: border-box;
            line-height: 28px;
        }
        .alertBtn{
            display: block;
            width: 100px;
            height: 34px;
            line-height: 34px;
            background-color: #3475f5;
            cursor: pointer;
            font-size: 14px;
            color: #fff;
            border-radius: 4px;
            border: 1px solid transparent;
            margin: 0 auto;
            text-align: center
        }
        .ConBtn{
            display: inline-block;
            width: 100px;
            height: 34px;
            line-height: 34px;
            background-color: #3475f5;
            cursor: pointer;
            font-size: 14px;
            color: #fff;
            border-radius: 4px;
            border: 1px solid transparent;
            text-align: center;
            margin-left: 84px;
            margin-right: 47px;
        }
        .cancel{
            display: inline-block;
            width: 100px;
            height: 34px;
            line-height: 34px;
            background:fff;
            cursor: pointer;
            font-size: 14px;
            color: #3475f5;
            border-radius: 4px;
            border: 1px solid transparent;
            text-align: center;
            border: 1px solid #3475f5;
        }

        .ToastBox{
            width: 452px;
            height: auto;
            padding: 15px 20px;
            text-align: center;
            background: rgba(0,0,0,.5);
            color: #fff;
            font-size: 16px;
            border-radius: 8px;
            line-height: 24px;
            position: relative;
            top: 50%;
            left: 50%;
            margin: 0px 0px 0px -226px;
        }
        /*弹窗的样式*/
        /*改video的坑*/
        video{
            height: 100% !important;
        }

        .input-group label.error {
            right: 100px !important;
        }
        .btn-file {
            overflow: visible !important;
        }

    </style>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <a class="glyphicon glyphicon-chevron-left returnToApartment" style="font-size: 20px" th:href="@{/system/apartment}"></a>
    <form class="form-horizontal m" id="form-apartment-edit" th:object="${apartment}">
        <div class="form-group">
            <input name="id" th:field="*{id}" class="form-control" type="hidden" required>
        </div>

        <div class="btn btn-default btn-xs" style="position: absolute;right: 15px; " onclick="reloadThisPage()">刷新
        </div>
        <div class="form-group">

            <label class="col-sm-3 control-label is-required">头部图片上传</label>
            <div class="col-sm-8">
                <label class="control-label">选择文件</label>
                <input class="projectfile" id="attach" multiple name="file"  type="file"  />
            </div>
        </div>

        <!--上传描述-->
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">描述：</label>
            <div class="col-sm-8" th:object="${apartmentDetail}">
                <textarea name="descript" th:utext="*{descript}"  style="resize:none;" maxlength="500" class="descript form-control valid" rows="3" required >*{descript}</textarea>

            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">点击跳转查看复制经纬度：</label>
            <div class="col-sm-8">
                <a target="_blank" class="btn btn-primary" href="https://api.map.baidu.com/lbsapi/getpoint/index.html">点击</a>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">经度(0-180)：</label>
            <div class="col-sm-8" th:object="${apartmentDetail}">
                <input name="latitude" th:value="*{latitude}" maxlength="500" class="latitude form-control valid" rows="3" required />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">纬度(0-90)：</label>
            <div class="col-sm-8" th:object="${apartmentDetail}">
                <input name="longitude" th:value="*{longitude}" maxlength="500" class="longitude form-control valid" rows="3" required />
            </div>
        </div>
        <div class="form-group" >
            <label class="col-sm-3 control-label is-required">电话号码：</label>
            <div class="col-sm-8" th:object="${apartmentDetail}">
                <input name="phone" th:value="*{phone}"  maxlength="500" class="phone form-control valid" rows="3" required/>
            </div>
        </div>


        <div class="btn btn-default btn-xs" style="position: absolute;right: 15px; " onclick="reloadThisPage()">刷新</div>
        <div class="form-group">

            <label class="col-sm-3 control-label is-required">详情图片上传</label>
            <div class="col-sm-8">
                <label class="control-label">选择文件</label>

                <input class="projectfile" id="attach1" multiple name="file"  type="file" />

            </div>
        </div>
        <div class="btn btn-default btn-xs" style="position: absolute;right: 15px; " onclick="reloadThisPage()">刷新</div>
        <div class="form-group">

            <label class="col-sm-3 control-label">详情视频上传</label>
            <div class="col-sm-8">
                <label class="control-label">选择文件</label>
                <input class="projectfile" id="video1" multiple name="file"  type="file" />
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label"></label>

            <div class="col-sm-8 " style="margin-top: 5px">
                <input type="button" onclick="submitDescription()" class="btn btn-primary col-xs-offset-10 col-sm-offset-11  col-md-offset-11" value="提交" required />
            </div>

        </div>



    </form>
</div>


<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<th:block th:include="include :: select2-css" />
<th:block th:include="include :: bootstrap-fileinput-css"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>


<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
<script th:inline="javascript" >
    $(function (){
        var prefix = ctx + "system/apartment";

        //详情页表的首页图片地址,包含html代码的,Headpic字段的
        var apartmentDetailHeadImageAddressObj="";
        //video的
        var apartmentDetailHeadVideoAddressObj="";
        //detail_pic字段的
        var apartmentDetailDetailImageAddressObj=[]
        //这个是原始headpic数据对象
        var apartmentDetailHeadImageAddressObjOrigin=[]
        //video的
        var apartmentDetailHeadVideoAddressObjOrigin=[]
        //detail_pic字段的
        var apartmentDetailDetailImageAddressObjOrigin=[]
        //从作用域中拿到id的值
        var id=0;

        //文件名加后缀
        var apartmentDetailImageAddressOnlyNameAndSuffix="";
        //删除的数组
        var deleteObjArr=[];
        var deleteDetailObjArr=[];
        var deleteObjVideoArr=[];
        var Ealt = new Eject();



        var vm=new Vue({
            data:{

            },
            methods:{
                videoUploder(){

                    $('#video1').fileinput({
                        maxFileCount:4,
                        language: 'zh', //设置语言
                        dropZoneTitle: '支持图片批量上传，最多1000M限制',//文字提醒
                        uploadUrl:'/system/apartment/detail/updatedetailvideosave',//上传地址
                        showRemove:false,
                        showUpload:false,  // showRemove, showUpload都为false时，不会显示拖拽框
                        enctype: 'multipart/form-data',
                        //maxFileCount: 10,//设置文件上传数量
                        maxFileattachSize: 1000 * 1024, //1000MB 文件上传限制大小
                        uploadAsync: false,//同步上传  后台参数为MultipartFile[]，若异步参数为MultipartFile
                        showCaption: true,
                        showPreview: true,
                        showCancel:false,
                        // "<video  class=\"kv-preview-data file-preview-video\" controls=\"\" src=\'http://www.aifanghome.top/apartmentDetail/dadb2d41212244408c40b0b7d1103d53.mp4\' class=\'file-preview-image\' alt=\'Desert\' title=\'Desert\'></video>"
                        initialPreview: apartmentDetailHeadVideoAddressObj,
                        initialPreviewConfig:deleteObjVideoArr,
                        autoReplace:true,//是否自动替换当前图片，默认为false
                        showUpload:false,//显示上传按钮
                        allowedFileExtensions: [ 'jpg','png','mp4'], //接收的文件后缀
                        uploadExtraData: function(){
                            return {id : [[${id}]]};//文件上传附带的参数
                        },

                    }).on("filebatchselected", function(event, files) {//选择文件后处理事件
                        $('.kv-file-upload').css("display","none");
                        if(files.length == 0){
                            alert("导入文件格式错误，只能选择pdf文件，请重新选择");
                        }
                    })




                }
                ,
                imageUploder(){

                    //上传功能
                    $('#attach').fileinput({
                        maxFileCount:4,
                        language: 'zh', //设置语言
                        dropZoneTitle: '支持图片批量上传，最多1000M限制',//文字提醒
                        uploadUrl:'/system/apartment/detail/updatepicsave',//上传地址
                        showRemove:false,
                        showUpload:false,  // showRemove, showUpload都为false时，不会显示拖拽框
                        enctype: 'multipart/form-data',
                        //maxFileCount: 10,//设置文件上传数量
                        maxFileattachSize: 1000 * 1024, //1000MB 文件上传限制大小
                        uploadAsync: false,//同步上传  后台参数为MultipartFile[]，若异步参数为MultipartFile
                        showCaption: true,
                        showPreview: true,
                        showCancel:false,
                        initialPreview: apartmentDetailHeadImageAddressObj,
                        initialPreviewConfig:deleteObjArr,
                        autoReplace:true,//是否自动替换当前图片，默认为false
                        showUpload:false,//显示上传按钮
                        allowedFileExtensions: [ 'jpg','png'], //接收的文件后缀
                        uploadExtraData: function(){
                            return {id : [[${id}]]};//文件上传附带的参数
                        }
                    }).on("fileuploaded", function (event, data, previewId, index){//上传成功后
                        console.log("event"+event+"data"+data+"previewId"+index)
                        //fileinput设置为异步时该回调函数生效
                        //上传成功后需要去拿新的初始化的数据,更新headpic

                        $.ajax({
                            // $('input[name="id"]').val()
                            url:"/system/apartment/detail/listByid?id="+[[${id}]],
                            type:"post",
                            async : false,
                            success:function (res){
                                //删除完出栈

                                console.log("listByid"+res)
                                //得到headpic数组对象
                                apartmentDetailHeadImageAddressObj=JSON.parse(res.headpic);
                                console.log("apartmentDetailHeadImageAddressObj",apartmentDetailHeadImageAddressObj)
                                apartmentDetailHeadImageAddressObjOrigin=JSON.parse(res.headpic);
                                for (var i = 0; i < apartmentDetailHeadImageAddressObj.length; i++) {
                                    //原来的对象

                                    apartmentDetailHeadImageAddressObj[i]= "<img src='"+apartmentDetailHeadImageAddressObj[i]+"' class='file-preview-image' alt='Desert' title='Desert'>";
                                }
                                apartmentDetailHeadImageAddressObj.pop();
                                apartmentDetailHeadImageAddressObjOrigin.pop()

                                //封装一个删除的对象
                                // {
                                //     width:'120px' ,
                                //         url:'/system/detail/deleteHeadpic' ,//服务器删除操作
                                //     extra:{id:10,fileName:"http://www.aifanghome.top/74d2e89b13f94ca0b61ff0cbaafbe928.jpg"}
                                // }

                                var deleteObj={width:'',url:'',extra:{id:0,fileName:''}};

                                for (var i = 0; i < apartmentDetailHeadImageAddressObjOrigin.length; i++) {
                                    deleteObj.width='120px';
                                    deleteObj.url='/system/apartment/detail/deleteHeadpic';
                                    deleteObj.extra.id=[[${id}]];

                                    deleteObj.extra.fileName=apartmentDetailHeadImageAddressObjOrigin[i];
                                    deleteObjArr.push(deleteObj);
                                }

                                $('#attach').fileinput({
                                    initialPreviewConfig:deleteObjArr
                                })
                            }


                        })


                    }).on("filebatchselected", function(event, files) {//选择文件后处理事件
                        $('.kv-file-upload').css("display","none");
                        if(files.length == 0){
                            alert("导入文件格式错误，只能选择pdf文件，请重新选择");
                        }
                    }).on("filebatchuploadsuccess", function(event, data, previewId, index) {
                        //fileinput设置为同步时该回调函数生效
                        hideLoading();
                        if(data.response.result == 'error'){
                            ToastUtils.error(data.response.msg);
                        }else {
                            alert(data.response.msg);
                            $("#attachUploadForm .kv-file-remove").click();//上传完清空附件
                            //全部上传完成后延迟0.5秒导出目标excel文件
                            setTimeout(function () {
                                var url = ctxPath + '/attach/export';
                                var values = new Array();
                                values.push($('input[name="uploadSn"]').val());
                                openWindowWithPost(url, '导出', [ 'uploadSn' ], values);
                            }, 500);
                        }
                    }).on('filesuccessremove', function (event, previewId, extra) {


                        //在移除事件里取出所需数据，并执行相应的删除指令
                        console.log("删除",event)


                    }).on('filepredelete', function(event, key, jqXHR, data){
                        console.log("删除前",event, key, jqXHR, data)
                        deleteObjArr.pop();
                        console.log(deleteObjArr);
                    });




                },
                //上传介绍的图片
                imageUploder1(){
                    //上传功能
                    $('#attach1').fileinput({
                        maxFileCount:4,
                        language: 'zh', //设置语言
                        dropZoneTitle: '支持图片批量上传，最多1000M限制',//文字提醒
                        uploadUrl:'/system/apartment/detail/updatedetailpicsave',//上传地址
                        showRemove:false,
                        showUpload:false,  // showRemove, showUpload都为false时，不会显示拖拽框
                        enctype: 'multipart/form-data',
                        //maxFileCount: 10,//设置文件上传数量
                        maxFileattachSize: 1000 * 1024, //1000MB 文件上传限制大小
                        uploadAsync: false,//同步上传  后台参数为MultipartFile[]，若异步参数为MultipartFile
                        showCaption: true,
                        showPreview: true,
                        showCancel:false,
                        initialPreview: apartmentDetailDetailImageAddressObj,
                        initialPreviewConfig:deleteDetailObjArr,
                        autoReplace:true,//是否自动替换当前图片，默认为false
                        showUpload:false,//显示上传按钮
                        allowedFileExtensions: [ 'jpg','png'], //接收的文件后缀
                        uploadExtraData: function(){
                            return {id : [[${id}]]};//文件上传附带的参数
                        }
                    }).on("fileuploaded", function (event, data, previewId, index){//上传成功后
                        console.log("event"+event+"data"+data+"previewId"+index)
                        //fileinput设置为异步时该回调函数生效
                        //上传成功后需要去拿新的初始化的数据,更新headpic

                        $.ajax({
                            // $('input[name="id"]').val()
                            url:"/system/apartment/detail/listByid?id="+[[${id}]],
                            async : false,
                            type:"post",
                            success:function (res){
                                //删除完出栈

                                console.log(res)
                                //得到headpic数组对象
                                apartmentDetailDetailImageAddressObj=JSON.parse(res.detailPic);
                                console.log("apartmentDetailDetailImageAddressObj",apartmentDetailDetailImageAddressObj)
                                apartmentDetailDetailImageAddressObjOrigin=JSON.parse(res.detailPic);
                                for (var i = 0; i < apartmentDetailDetailImageAddressObj.length; i++) {
                                    //原来的对象

                                    apartmentDetailDetailImageAddressObj[i]= "<img src='"+apartmentDetailDetailImageAddressObj[i]+"' class='file-preview-image' alt='Desert' title='Desert'>";
                                }


                                //封装一个删除的对象
                                // {
                                //     width:'120px' ,
                                //         url:'/system/detail/deleteHeadpic' ,//服务器删除操作
                                //     extra:{id:10,fileName:"http://www.aifanghome.top/74d2e89b13f94ca0b61ff0cbaafbe928.jpg"}
                                // }

                                var deleteObj={width:'',url:'',extra:{id:0,fileName:''}};

                                for (var i = 0; i < apartmentDetailDetailImageAddressObjOrigin.length; i++) {
                                    deleteObj.width='120px';
                                    deleteObj.url='/system/apartment/detail/deletedetailHeadpic';
                                    deleteObj.extra.id=[[${id}]];

                                    deleteObj.extra.fileName=apartmentDetailHeadImageAddressObjOrigin[i];
                                    deleteObjArr.push(deleteObj);
                                }

                                $('#attach').fileinput({
                                    initialPreviewConfig:deleteDetailObjArr
                                })
                            }


                        })


                    }).on("filebatchselected", function(event, files) {//选择文件后处理事件
                        $('.kv-file-upload').css("display","none");
                        if(files.length == 0){
                            alert("导入文件格式错误，只能选择pdf文件，请重新选择");
                        }
                    }).on("filebatchuploadsuccess", function(event, data, previewId, index) {
                        //fileinput设置为同步时该回调函数生效
                        hideLoading();
                        if(data.response.result == 'error'){
                            ToastUtils.error(data.response.msg);
                        }else {
                            alert(data.response.msg);
                            $("#attachUploadForm .kv-file-remove").click();//上传完清空附件
                            //全部上传完成后延迟0.5秒导出目标excel文件
                            setTimeout(function () {
                                var url = ctxPath + '/attach/export';
                                var values = new Array();
                                values.push($('input[name="uploadSn"]').val());
                                openWindowWithPost(url, '导出', [ 'uploadSn' ], values);
                            }, 500);
                        }
                    }).on('filesuccessremove', function (event, previewId, extra) {


                        //在移除事件里取出所需数据，并执行相应的删除指令
                        console.log("删除",event)


                    }).on('filepredelete', function(event, key, jqXHR, data){
                        console.log("删除前",event, key, jqXHR, data)
                        deleteObjArr.pop();
                        console.log(deleteObjArr);
                    });



                },
                //初始化数据
                initData(){

                    //得到上传headPic的图片地址
                    $.ajax({
                        // $('input[name="id"]').val()
                        url:"/system/apartment/detail/listByid?id="+[[${id}]],
                        async : false,
                        type:"post",
                        success:function (res){
                            console.log(res)
                            //得到headpic数组对象s

                            apartmentDetailHeadImageAddressObj=JSON.parse(res.headpic);
                            apartmentDetailHeadVideoAddressObj=JSON.parse(res.videoAddress);
                            // apartmentDetailVedioAddressObj=JSON.parse(res.headpic);
                            console.log("241"+apartmentDetailHeadImageAddressObj);
                            console.log("232res.detailPic",res)
                            apartmentDetailDetailImageAddressObj=JSON.parse(res.detailPic);
                            console.log("92apartmentDetailDetailImageAddressObj",apartmentDetailDetailImageAddressObj)
                            apartmentDetailHeadImageAddressObjOrigin=JSON.parse(res.headpic);
                            //视频的原始数据
                            apartmentDetailHeadVideoAddressObjOrigin=JSON.parse(res.videoAddress);
                            console.log("res.videoAddress",res.videoAddress)
                            console.log("apartmentDetailHeadVideoAddressObjOrigin",apartmentDetailHeadVideoAddressObjOrigin)
                            apartmentDetailDetailImageAddressObjOrigin=JSON.parse(res.detailPic);

                            console.log("apartmentDetailDetailImageAddressObjOrigin",apartmentDetailDetailImageAddressObjOrigin)
                            for (var i = 0; i < apartmentDetailHeadImageAddressObj.length; i++) {
                                //原来的对象

                                apartmentDetailHeadImageAddressObj[i]= "<img src='"+apartmentDetailHeadImageAddressObj[i]+"' class='file-preview-image' alt='Desert' title='Desert'>";
                            }
                            for (var i = 0; i < apartmentDetailDetailImageAddressObj.length; i++) {
                                //原来的对象

                                apartmentDetailDetailImageAddressObj[i]= "<img src='"+apartmentDetailDetailImageAddressObj[i]+"' class='file-preview-image' alt='Desert' title='Desert'>";
                            }
                            //拼接视频的初始数据
                            for (var i = 0; i < apartmentDetailHeadVideoAddressObj.length; i++) {
                                //原来的对象

                                apartmentDetailHeadVideoAddressObj[i] = "<video  class=\"kv-preview-data file-preview-video\" controls=\"\" src='" + apartmentDetailHeadVideoAddressObj[i] + "' class=\'file-preview-image\' alt=\'Desert\' title=\'Desert\'></video>";
                            }
                            console.log("549apartmentDetailHeadVideoAddressObj"+apartmentDetailHeadVideoAddressObj)

                            //封装一个删除的对象
                            // {
                            //     width:'120px' ,
                            //         url:'/system/detail/deleteHeadpic' ,//服务器删除操作
                            //     extra:{id:10,fileName:"http://www.aifanghome.top/74d2e89b13f94ca0b61ff0cbaafbe928.jpg"}
                            // }

                            var deleteObj={width:'',url:'',extra:{id:0,fileName:''}};
                            var deleteDetailDetailObj={width:'',url:'',extra:{id:0,fileName:''}};

                            console.log("562apartmentDetailHeadVideoAddressObjOrigin",apartmentDetailHeadVideoAddressObjOrigin);
                            for (var i = 0; i < apartmentDetailHeadVideoAddressObjOrigin.length; i++) {
                                deleteObj={width:'',url:'',extra:{id:0,fileName:''}};
                                deleteObj.width='120px';
                                deleteObj.url='/system/apartment/detail/deleteDetailDetailVideo';
                                deleteObj.extra.id=[[${id}]];
                                deleteObj.extra.fileName=''+apartmentDetailHeadVideoAddressObjOrigin[i];
                                console.log("apartmentDetailHeadImageAddressObjOrigin[i]"+apartmentDetailHeadVideoAddressObjOrigin[i])
                                deleteObjVideoArr.push(deleteObj);
                            }

                            for (var i = 0; i < apartmentDetailHeadImageAddressObjOrigin.length; i++) {
                                deleteObj={width:'',url:'',extra:{id:0,fileName:''}};
                                deleteObj.width='120px';
                                deleteObj.url='/system/apartment/detail/deleteHeadpic';
                                deleteObj.extra.id=[[${id}]];
                                deleteObj.extra.fileName=''+apartmentDetailHeadImageAddressObjOrigin[i];
                                console.log("apartmentDetailHeadImageAddressObjOrigin[i]"+apartmentDetailHeadImageAddressObjOrigin[i])
                                deleteObjArr.push(deleteObj);
                            }
                            for (var i = 0; i < apartmentDetailDetailImageAddressObjOrigin.length; i++) {

                                deleteDetailDetailObj={width:'',url:'',extra:{id:0,fileName:''}};
                                deleteDetailDetailObj.width='120px';
                                deleteDetailDetailObj.url='/system/apartment/detail/deleteDetailDetailpic';
                                deleteDetailDetailObj.extra.id=[[${id}]];
                                deleteDetailDetailObj.extra.fileName=''+apartmentDetailDetailImageAddressObjOrigin[i];
                                console.log("apartmentDetailHeadImageAddressObjOrigin[i]"+apartmentDetailDetailImageAddressObjOrigin[i])
                                //得到img_detail的数组
                                deleteDetailObjArr.push(deleteDetailDetailObj);
                            }


                            console.log("138apartmentDetailDetailImageAddressObjOrigin",apartmentDetailDetailImageAddressObjOrigin)


                            console.log("apartmentDetailDetailImageAddressObj283"+apartmentDetailDetailImageAddressObj);

                            //判断文件是不是必须上传
                            if(apartmentDetailHeadImageAddressObjOrigin.length!=0){
                                // 285
                                console.log("apartmentDetailHeadImageAddressObj286",apartmentDetailHeadImageAddressObj.length)

                            }else{
                                $("#attach").attr("required","true")
                            }

                            if(apartmentDetailDetailImageAddressObjOrigin.length!=0){
                                // 285
                                console.log("apartmentDetailHeadImageAddressObj286",apartmentDetailDetailImageAddressObj.length)

                            }else{
                                $("#attach1").attr("required","true")
                            }
                            //视频不是必需的

                        }

                    })

                    //点击上传事件
                    $('#save').click(function(){
                        if($("#attach").val() != ""){
                            $("#").fileinput("upload");
                            showLoading();
                        }
                    });







                }
            },
            created(){


                this.initData()
                console.log("454apartmentDetailDetailImageAddressObjOrigin",apartmentDetailDetailImageAddressObjOrigin)
                this.imageUploder()
                this.imageUploder1()
                this.videoUploder();
            },
        });







    })












    // 从路径得到资源的名字和后缀
    String.prototype.replaceAll = function(s1, s2) {
        return this.replace(new RegExp(s1, "gm"), s2);
    }
    // 得到url的参数值的函数
    function  GetQueryString(name)
    {
        var  reg =  new  RegExp( "(^|&)" + name + "=([^&]*)(&|$)" );
        var  r = window.location.search.substr(1).match(reg);
        if (r!= null ) return   unescape(r[2]);  return  null ;
    }

    function submitDescription(){
        $("#form-apartment-edit").validate({
            focusCleanup: true
        });

        if ($.validate.form()) {
            //头部的图片延时上传
            //得到将要上传的文件数量
            var mount=$(".kv-file-upload").length;
            console.log("mount"+mount)
            // $.modal.loading("正在导出数据，请稍后...");

            //批量上传
            for (var i=1;i<=mount;i++){
                console.log("iiii"+i)

                console.log($)
                startWorker()

                $(".file-preview-thumbnails .kv-preview-thumb:nth-child("+i+") .kv-file-upload").trigger("click");
                console.log("头部的图片延时上传")
                // 打开遮罩层



            }




            $.ajax({
                type: "post",
                url: "/system/apartment/detail/updateSave",
                async : false,
                data: {
                    id: [[${id}]],
                    descript: $('.descript').val(),
                    latitude: $('.latitude').val(),//经度
                    longitude: $('.longitude').val(),//纬度
                    phone: $('.phone').val(),//纬度


                },
                success: function (res) {
                    $.modal.msgSuccess('成功插入');

                }
            });
        }
    }
    //弹窗
    function Eject(){
        var _this = this;
        // 全屏遮罩背景
        var qback = $('<div class="qback"></div>')
        // alert提示窗
        _this.Ealert = function(obj){
            var alertBox = $('<div class="alertBox"></div>')
            var alertHead = $('<div class="alertHead">'+obj.title+'</div>')
            var alertMes = $('<div class="alertMes">'+obj.message+'</div>')
            var alertBtn = $('<span class="alertBtn">确定</span>').on('click',function(){
                qback.remove();
                alertBox.remove();
            })
            alertBox.append(alertHead);
            alertBox.append(alertMes);
            alertBox.append(alertBtn);
            qback.append(alertBox);
            $('body').append(qback);
            alertBox.css({'marginTop':-alertBox.outerHeight()/2+'px'});
        }
        // confirm弹窗
        _this.Econfirm = function(obj){
            var confirmBox = $('<div class="alertBox"></div>')
            var confirmHead = $('<div class="alertHead">'+obj.title+'</div>')
            var confirmMes = $('<div class="alertMes">'+obj.message+'</div>')
            var confirmBtn = $('<span class="ConBtn">确定</span>').on('click',function(){
                qback.remove()
                confirmBox.remove()
                setTimeout(function(){
                    obj.define()
                },100)
            })
            var confirmcancel = $('<span class="cancel">取消</span>').on('click',function(){
                qback.remove()
                confirmBox.remove()
                setTimeout(function(){
                    obj.cancel()
                },100)
            })
            confirmBox.append(confirmHead);
            confirmBox.append(confirmMes);
            confirmBox.append(confirmBtn);
            confirmBox.append(confirmcancel);
            qback.append(confirmBox);
            $('body').append(qback);
            confirmBox.css({'marginTop':-confirmBox.outerHeight()/2+'px'});
        },
            // toast提示
            _this.Etoast = function(mes,time){
                var timer= null;
                var ToastBox = $('<div class="ToastBox">'+mes+'</div>')
                qback.append(ToastBox);
                $('body').append(qback);
                ToastBox.css({'marginTop':-ToastBox.outerHeight()/2+'px'});
                clearInterval(timer)
                timer = setInterval(function(){
                    time--
                    if(time<=0){
                        clearInterval(timer)
                        qback.remove()
                        ToastBox.remove()
                    }
                },1000)
            }
    }
    //休眠一秒的函数
    function sleep(numberMillis) {

        var now = new Date();
        var exitTime = now.getTime() + numberMillis;
        while (true) {
            now = new Date();
            if (now.getTime() > exitTime)
                return true;
        }
    }
    var w;
    function startWorker() {
        if(typeof(Worker) !== "undefined") {
            if(typeof(w) == "undefined") {
                w = new Worker("/js/demo_workers.js");

            }
            w.onmessage = function(event) {
                console.log("xxx")

            };
        } else {
            document.getElementById("result").innerHTML = "抱歉，你的浏览器不支持 Web Workers...";
        }

    }

    function reloadThisPage(){
        location.reload();
    }




</script>
</body>
</html>